package com.group.service.impl;

import com.group.mapper.UserMapper;
import com.group.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.entity.Record;
import pojo.entity.Records;
import pojo.entity.User;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public User queryUserByName(String name) {
        return userMapper.queryUserByName(name);
    }

    @Override
    public List<User> findAllUser() {
        return userMapper.selectAllUser();
    }

    @Override
    public int removeUser(Long id) {
        return userMapper.deleteUser(id);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int addUser(User user) {
        return userMapper.insertUser(user);
    }

    @Override
    public void addRecords(Records records) {
        System.out.println(records);
        userMapper.addRecords(records);
    }

    @Override
    public User findUserById (Long userId){
        User user = userMapper.selectById(userId);
        return user;
    }
}
